Find all adverbs and their positions¶
for m in re.finditer(r”w+ly”, S)
Find all adverbs and their positions in a given sentence.
Sample text :
“Clearly, he has no excuse for such behavior.”
import re
S = "Clearly, he has no excuse for such behavior."
for m in re.finditer(r"\w+ly", S):
print('%d-%d: %s' % (m.start(), m.end(), m.group(0)))
Output:
0-7: Clearly